package com.itheima.mapper;

import com.github.pagehelper.Page;
import com.itheima.pojo.Emp;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface EmpMapper {
//        @Select("select dept.name deptName, emp.*\n" +
//                "        from emp,dept where dept.id = emp.dept_id\n" +
//                "        limit #{startIndex},#{pageSize}")
//        List<Emp> list(Integer startIndex,Integer pageSize);

//        @Select("select count(*) from emp,dept where dept.id= emp.dept_id")
//        Long count();

    Page<Emp> list(String name, Integer gender, LocalDate begin, LocalDate end);

    /**
     * 新增员工数据
     *
     * @Options：返回主键
     */
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into emp(username, name, gender, phone, job, salary, image, entry_date, dept_id, create_time, update_time) " +
            "values (#{username},#{name},#{gender},#{phone},#{job},#{salary},#{image},#{entryDate},#{deptId},#{createTime},#{updateTime})")
    void insert(Emp emp);


    void deleteByIds(List<Integer> ids);

    Emp getInfo(Integer id);

    void updateById(Emp emp);

    List<Emp> getTeacherList();

    Emp getUsernameAndPassword(Emp emp);
}
